home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
util
/
arc
/
CheckX.lha
/
CheckX
/
sources
/
StartCode.a
< prev
next >
Wrap
Text File
|
1999-02-11
|
1KB
|
50 lines
INCLUDE AINCLUDE:IncDirs.i
INCLUDE exec/libraries.i
INCLUDE exec/tasks.i
INCLUDE exec/memory.i
INCLUDE lvo.i
XREF @start
* Could not do that in main program, because of C language limitations
*
* This is not required (e.g. You can compile the main program without that
* start header), but may increase stability for files with really deep
* recursion (I have a file with up to 23 link levels).
STACKSIZE EQU 10240
MOVEA.L 4.W,A6
CMP.L #37,LIB_VERSION(A6) * we need OS2.0 to use StackSwap
BLO.B start
MOVE.L #STACKSIZE,D2
SUBA.L A1,A1
JSR _LVOFindTask(A6)
MOVE.L D0,A0
MOVE.L TC_SPUPPER(A0),D0 * calculate current size
SUB.L TC_SPLOWER(A0),D0
CMP.L D2,D0
BGE.B start * enough ? then do nothing
MOVE.L D2,D0
MOVEQ #MEMF_PUBLIC,D1
JSR _LVOAllocMem(A6) * get memory
MOVE.L D0,D3
BEQ.B start * failed ? call without StackSwap
LEA -StackSwapStruct_SIZEOF(A7),A7
MOVE.L A7,A4
MOVE.L D0,stk_Lower(A4) * initialize StackSwapStruct
ADD.L D2,D0
MOVE.L D0,stk_Upper(A4)
MOVE.L D0,stk_Pointer(A4)
MOVEA.L A4,A0
JSR _LVOStackSwap(A6) * swap stack
JSR @start(PC) * call main function
MOVEA.L A4,A0
JSR _LVOStackSwap(A6) * swap stack back
LEA StackSwapStruct_SIZEOF(A7),A7
MOVEA.L D3,A1
MOVE.L D2,D0
JMP _LVOFreeMem(A6) * free stack and return (JMP)
start JMP @start(PC)
END